package Hw_06;

/**
 * 定义一个Person类，含姓名，性别，年龄等字段；集成Person；
 * 类设计Teacher类，增加工号、薪水、职称，部门等字段
 * 集成Person类设计Student类，增加学号，入学时间，专业等字段。
 * 定义各类的构造方法和toString()方法。
 */
public class Person {
    private String name;
    private String sex;
    private int age;

    public Person(){

    }

    public Person(String name, String sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

}
class Teacher extends Person{
    private int ID;//工号
    private int pay;//薪资
    private String named;//职称
    private String sector;//部门

    public Teacher(int ID, int pay, String named, String sector) {
        this.ID = ID;
        this.pay = pay;
        this.named = named;
        this.sector = sector;
    }
    public String toString(){
        return  "姓名："+ this.getName() +
                ",性别:" + this.getSex() +
                ",年龄:" + this.getAge() +
                ",工号:" + this.ID +
                ",薪资:" + this.pay +
                ",职称:" + this.named +
                ",部门:" + this.sector;


    }
}
class Student extends Person{
    int num;//学号
    int time;//入学时间
    String major;//专业

    public Student(String name, String sex, int age, int num, int time, String major) {
        this.setName(name);
        this.setAge(age);
        this.setSex(sex);
        this.num = num;
        this.time = time;
        this.major = major;
    }
    public String toString(){
        return  "姓名:" + this.getName() +
                ",性别:" + this.getSex() +
                ",年龄:" + this.getAge() +
                ",学号:" + this.num +
                ",入学时间:" + this.time +
                ",专业:" + this.major;
    }
    public static void main(String[] args) {
        Teacher A = new Teacher(8888,3500,"教授","教育");
        Student B = new Student("李四","男",19,0001,201909,"计算机");
        System.out.println(A.toString());
        System.out.println(B.toString());
    }
}


